{% extends 'base.html' %}
{% block list-main %}
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-3 col-md-2 sidebar">
                <ul class="nav nav-sidebar">
                    <li><a href="/publisher_list/">出版社列表</a></li>
                    <li class="active"><a href="/book_list/">书籍列表</a></li>
                    <li><a href="/author_list/">作者列表</a></li>
                    <li><a href="#">ccc</a></li>
                </ul>

            </div>
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="panel panel-primary">
                    <!-- Default panel contents -->
                    <div class="panel-heading">编辑书籍 <i class="fa fa-thumb-tack pull-right"></i></div>
                    <div class="panel-body">
                        <form action="/edit_book/" method="post" class="form-horizontal">
                            <div class="form-group">
                                <div class="col-sm-5">
                                    <input type="text" name="id" value="{{ book.id }}" style="display: none">
                                    <input type="text" name="book_name" value="{{ book.name }}" class="form-control">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-5">
                                    <label for="s1">编辑作者</label>
                                    <select multiple name="edit_au" class="form-control" id="s1">
                                    {% for author in author_list %}
                                        {% if author in book.authors.all %}
                                            <option value="{{ author.id }}" selected>{{ author.name }}</option>
                                        {% else %}
                                            <option value="{{ author.id }}">{{ author.name }}</option>
                                        {% endif %}
                                    {% endfor %}
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-5">
                                    <label for="s1">编辑出版社</label>
                                    <select name="edit_pub" class="form-control" id="s1">
                                    {% for publisher in publisher_list %}
                                        {% if publisher.id == book.publisher_id %}
                                            <option value="{{ publisher.id }}" selected>{{ publisher.name }}</option>
                                        {% else %}
                                            <option value="{{ publisher.id }}">{{ publisher.name }}</option>
                                        {% endif %}
                                    {% endfor %}
                                    </select>
                                </div>
                            </div>

                            <button type="submit" class="btn btn-success">提交</button>
                            <p style="color: red">{{ error }}</p>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}